How many different shades of the color blue can you name? Post as many as you can think of. We'll take a look at the board together once everyone has posted.
Last lesson, we looked at black and white pictures and how we can represent them using binary.
What did you notice about the size of the binary as you increased the size of the images you drew?
Today, we're going to see how the relationship between analog and digital plays out in the world of color. You'll get a chance to play with the pixelation widget again, but this time you'll use it to make your own color blends, or gradients.
But first, we need to look at how color works inside the pixelation widget.
Last lesson, we used 1 bit for each pixel. That meant we had only two choices for each pixel: black or white.
You could think of each bit like a light switch.
Now we'll use at least 3 bits for each pixel. Think of each bit as a switch that controls a different color of light inside the pixel: red, green, and blue.
Turning on the first bit turns on the red light and makes the pixel red.
Turning on the second bit turns on the green light and makes the pixel green.
Turning on the first and second bits turns on both the red and green lights, making the pixel yellow.
With three bits, we can have 8 colors in total, since 23 = 8.
What color would you get if all the bits are 0?
All the lights in the pixel are off, so we get black.
What color would we get if all of the bits are on?
White. Red, green, and blue are additive primaries: when we add all of them together, we get white.
Follow this link to code.org to complete level 2.
Check the metadata: the first 3 bytes of each image's data describe what the bits that come after mean. Look at the top left corner for a diagram. These bytes are the image's metadata: data about the data.
Follow the same link to code.org to complete levels 4 through 9.
Check in with your partner as you complete each level to double check your work.
In computer science, abstractions come up a lot, and images are no different. Each layer builds on the one beneath it, without needing to know exactly how that lower layer works.
A digital approximation of an analog image, made up of a grid of pixels.
Sampling reads equally sized parts of the analog image and assigns each part to a pixel.
Each pixel holds levels of red, green, and blue light that describe its color.
Those color levels are represented using a sequence of binary numbers, carried as electrical signals.